﻿#region Imports
using System;
using System.Globalization;
using System.Windows.Data;
using CheckerWPF.Utils;
#endregion

namespace CheckerWPF.Converters
{
    public class OptionCheckerConverter : IValueConverter
    {
        #region Converters
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool val = false;
            if (Utilities.IsBoolean(value))
            {
                val = System.Convert.ToBoolean(value);
                if (System.Convert.ToString(parameter).ToUpper() == "N") val = !val;
            }

            return val;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool val = false;
            if (Utilities.IsBoolean(value))
            {
                val = System.Convert.ToBoolean(value);
                if (System.Convert.ToString(parameter).ToUpper() == "N") val = !val;
            }

            return val;
        }
        #endregion

        #region Methods
        #endregion
    }
}
